﻿/*******************************************************
* Copyright (c) 2018-2088, By XuXiang all rights reserved.
*
* FileName: CommandProcesser.cpp
* Summary: 命令处理。
*
* Author: XuXiang
* Date: 2024-04-10 14:56
*******************************************************/

#include "CommandProcesser.h"
#include "ServerGame.h"
#include <Frame/MainBase.h>
#include <Frame/NetManagerBase.h>
#include <Frame/ModuleBase.h>
#include <Util/StringUtil.h>

namespace Competition
{
	CommandProcesser::CommandProcesser() : m_Server(NULL)
	{
	}

	CommandProcesser::~CommandProcesser()
	{
	}

	CommandProcesser* CommandProcesser::GetInstance()
	{
		static CommandProcesser cmd;
		return &cmd;
	}

	void CommandProcesser::Init(ServerGame *server)
	{
		m_Server = server;
	}

	void CommandProcesser::OnCommand(const std::string& cmd, const std::vector<std::string> &param)
	{
		//std::cout << "OnCommand " << cmd << endl;
		if (cmd == "/close")
		{
			if (param.size() > 0)
			{
				int uid = ::atoi(param[0].c_str());
				std::cout << "Close " << uid << endl;
				MainBase::GetCurMain()->GetNetManager()->Close(uid);
			}
		}
	}
}